package service

import (
	"geekai/core/types"
	"go.uber.org/fx"
)

// RegisterServiceObj 注册Service
func RegisterServiceObj() fx.Option {
	return fx.Module("service",
		fx.Provide(NewUserService),
		fx.Provide(NewSmtpService),
		fx.Provide(NewWebSocketService),
		fx.Provide(NewSnowflake),
		fx.Provide(NewXXLJobExecutor),
		// 启动 XXL-JOB 定时任务
		fx.Invoke(func(exec *XXLJobExecutor, config *types.AppConfig) {
			if config.XXLConfig.Enabled {
				go func() {
					log.Fatal(exec.Run())
				}()
			}
		}),
	)
}
